﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebStudio.Business.Rule;

public partial class Admin_ArticleMge : System.Web.UI.Page
{
   // BArticle bArticle = new BArticle();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Admin_User"] == null || Session["Admin_User"].ToString() == "")
        {
            Response.Redirect("~/Admin/Login.aspx");
        }
        if (!Page.IsPostBack)
        {
            InitPage();
        }
    }

    private void InitPage()
    {
        anpList.PageSize = 15;
        anpList.CurrentPageIndex = 1;
        anpList.RecordCount = ArticalRule.GetArticalListCount("1");
        rptArticleBind();
    }

    private void rptArticleBind()
    {
        rptArticle.DataSource = ArticalRule.GetArticalList(anpList.CurrentPageIndex, anpList.PageSize, anpList.PageCount, anpList.RecordCount, 0, 0, "1");
        rptArticle.DataBind();
    }

    protected void rptArticle_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            LinkButton lbtnDelete = e.Item.FindControl("lbtnDelete") as LinkButton;
            ArticalRule.DeleteArticalInfor(Convert.ToInt32(lbtnDelete.CommandArgument));
            rptArticleBind();
        }
    }

    protected void anpList_PageChanged(object sender, EventArgs e)
    {
        rptArticleBind();
    }
}
